<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    var num = 10;
    for (i = 1; i <= num; i++){
        for (p = 0; p < num - i; p++){
            document.write("&nbsp");
        }
        for ( j = 0; j < 2 * i - 1; j++){
            document.write("*");
        }
        document.write("<br>")
    }

</script>
</body>
</html>